<?php

/**
 * Description of userauth
 *
 * @author Nazmul
 */
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Userauth {

    var $CI = NULL;
    var $role = 'admin'; // Admin,Owner,Buyer
    var $user = array();

    public function __construct() {
        $this->CI = &get_instance();
        $this->CI->load->library('session');
    }

    public function setUserInfo(array $userInfo, $usertype) {
        $this->role = $usertype;
        // set value :: login data to session array
        $this->user['pkid'] = $userInfo['pkid'];
        $this->user['name'] = $userInfo['name'];
        $this->user['username'] = $userInfo['username'];
        $this->user['email'] = $userInfo['email'];
        $this->user['isloggedin'] = true;

        // set user info
        $this->CI->session->set_userdata($this->user);
    }

    public function getUserRole() {
        return $this->role;
    }

    // get biz owner method
    public function isLoggedIn() {
        return $this->CI->session->userdata('isloggedin');
    }

    # user information

    public function pkId() {
        return $this->CI->session->userdata('pkid');
    }

    public function userId() {
        return $this->CI->session->userdata('user_id');
    }

    public function userName() {
        return $this->CI->session->userdata('username');
    }

    public function email() {
        return $this->CI->session->userdata('email');
    }

    // destroy user session
    public function setUserLogOut() {
        $this->CI->session->sess_destroy();
    }

    // ## this part for Biz Owner Start
}

/* End of file userauth.php */
/* Location: ./application/libraries/userauth.php */ 